package com.cjxt.ams.utils;

import com.cjxt.ams.domain.TreeNode;
import com.cjxt.ams.domain.TreeNodeUser;

import java.util.LinkedList;
import java.util.List;

/**
 * @author fangzhiyu
 * @version V1.0
 * @Description:
 * @className: TreeNodeUtil
 * @date 2021/12/8 15:03
 * @company:华勤技术股份有限公司
 * @copyright: Copyright (c) 2021
 */


public class TreeNodeUtil {

    public static List<TreeNode> transformData(List<TreeNode> treeNodeList, Integer pid){
        List<TreeNode> list=new LinkedList<TreeNode>();
        for (TreeNode node:treeNodeList){
            if (node.getPid().equals(pid)){
                node.setChildren(transformData(treeNodeList,node.getId()));
                list.add(node);
                System.out.println(list.size());
            }
        }
        return list;
    }

    public static List<TreeNodeUser> transformData2(List<TreeNodeUser> treeNodeList, Integer pid){
        List<TreeNodeUser> list=new LinkedList<TreeNodeUser>();
        for (TreeNodeUser node:treeNodeList){
            if (node.getPid().equals(pid)){
                node.setChildren(transformData2(treeNodeList,node.getId()));
                list.add(node);
                System.out.println(list.size());
            }
        }
        return list;
    }



}
